<template>
  <common-page
    ref="commonPage"
    :bg-path="bgPath"
    :web-path="webPath"
    :columns="columns"
    :search-items="searchItems"
    :form-items="formItems"
  />
</template>
<script>
export default {
  data() {
    return {
      // ===== ===== ===== ===== 全局属性 ===== ===== ===== =====
      // 后台接口路径
      bgPath: 'health/diagnosis/inspct/pickinspectcontent',
      // Web路径
      webPath: 'health/diagnosis/inspct/pickinspectcontent',
      // ===== ===== ===== ===== 页面配置 ===== ===== ===== =====
      // 搜索内容
      searchItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "inspectTypeCode",
              name: "检测结果类型",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "inspectTypeName",
              name: "检测结果类型名称",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "contentInfoCode",
              name: "内容编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "contentInfoName",
              name: "内容名称",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "storeCode",
              name: "门店编码",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "storeName",
              name: "门店名称",
              span: 6,
              type: "text",
              config: {
                edit: false
              }
            },
            {
              code: "sexSign",
              name: "性别标识",
              type: "select",
              config: {
                options: [
                  { key: "1", value: "男" },
                  { key: "2", value: "女" }
                ]
              }
            },
            {
              code: "defSign",
              name: "默认标识",
              type: "select",
              config: {
                options: [
                  { key: "0", value: "否" },
                  { key: "1", value: "是" }
                ]
              }
            }
          ]
        }
      ],
      // 列表内容
      columns: [
        {
          code: "inspectTypeCode",
          name: "检测结果类型编码",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "inspectTypeName",
          name: "检测结果类型名称",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "contentInfoCode",
          name: "内容编码",
          span: 6,
          type: "text",
          config: {
            edit: false
          }
        },
        {
          code: "sexSign",
          name: "性别标识",
          type: "select",
          config: {
            options: [
              { key: "1", value: "男" },
              { key: "2", value: "女" }
            ],
            edit: false
          }
        },
        {
          code: "defSign",
          name: "默认标识",
          type: "select",
          config: {
            options: [
              { key: "0", value: "否" },
              { key: "1", value: "是" }
            ],
            edit: false
          }
        },
        {
          code: "contentWeight",
          name: "内容权重",
          type: "number",
          config: {
            precision: 2,
            edit: false
          }
        }
      ],
      // 增加/修改/详情 表单
      formItems: [
        {
          rowIndex: 1,
          items: [
            {
              code: "inspectTypeCode",
              span: 6,
              name: "检测结果类型编码",
              type: "popup",
              config: {
                url: "health/diagnosis/inspct/inspecttype",
                filedList: [
                  { code: 'id', name: 'Id' },
                  { code: 'code', name: '编码' },
                  { code: 'name', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                rules: [
                  { required: true, message: '请选择检测结果类型', trigger: 'change' }
                ]
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  this.$refs.commonPage.updateFormData(code, row.code)
                  this.$refs.commonPage.updateFormData("inspectTypeName", row.name)
                  this.$refs.commonPage.updateFormData("inspectTypeId", row.id)
                }
              }
            },
            {
              code: "inspectTypeName",
              name: "检查结果类型名称",
              type: "text",
              span: 6,
              config: {
                edit: false,
                require: false,
                disabled: true
              }
            },
            {
              code: "contentInfoCode",
              span: 6,
              name: "内容编码",
              type: "popup",
              config: {
                url: "health/content/label/contentinfo",
                filedList: [
                  { code: 'id', name: 'Id' },
                  { code: 'code', name: '编码' },
                  { code: 'conName', name: '名称' }
                ],
                searcher: {},
                defaultValue: "",
                minLength: 0,
                maxLength: 20,
                disabled: false,
                rules: [
                  { required: true, message: '请选择内容', trigger: 'change' }
                ]
              },
              handleEvent: {
                /**
                 * 开窗组件被选择
                 * @param code
                 * @param row
                 */
                onPopupClick: (code, row) => {
                  this.$refs.commonPage.updateFormData(code, row.code)
                  this.$refs.commonPage.updateFormData("contentInfoName", row.conName)
                  this.$refs.commonPage.updateFormData("contentInfoId", row.id)
                }
              }
            },
            {
              code: "sexSign",
              name: "性别标识",
              type: "select",
              span: 6,
              config: {
                options: [
                  { key: "1", value: "男" },
                  { key: "2", value: "女" }
                ]
              }
            },
            {
              code: "defSign",
              name: "默认标识",
              span: 6,
              type: "select",
              config: {
                options: [
                  { key: "0", value: "否" },
                  { key: "1", value: "是" }
                ]
              }
            },
            {
              code: "contentWeight",
              name: "内容权重",
              type: "number",
              span: 6,
              config: {
                precision: 2
              }
            }
          ]
        }
      ]
    }
  }
}
</script>
